<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: image_processing_new_step2.php 11 2013-09-21 11:43:11Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 11 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 11:43:11 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

defined( '_VALID_XTC' ) or die( 'Direct Access to this location is not allowed.' );

define('MODULE_NEW_STEP2_IMAGE_PROCESS_TEXT_DESCRIPTION', 'Imageprocessing - Stapelverarbeitung mit leeren Verzeichnissen step-by-step Variante D');
define('MODULE_NEW_STEP2_IMAGE_PROCESS_TEXT_TITLE', 'Imageprocessing-New (mit leeren Verzeichnissen step-by-step Variante D)');
define('MODULE_NEW_STEP2_IMAGE_PROCESS_STATUS_DESC','Modulstatus');
define('MODULE_NEW_STEP2_IMAGE_PROCESS_STATUS_TITLE','Status');
define('IMAGE_EXPORT','Dr&uuml;cken Sie Ok um die Stapelverarbeitung zu starten, dieser Vorgang kann einige Zeit dauern, auf keinen Fall unterbrechen!.');
define('IMAGE_EXPORT_TYPE','<hr noshade><b>Stapelverarbeitung:</b>');

class image_processing_new_step2 {
    var $code, $title, $description, $enabled, $db;

    function image_processing_new_step2() {
		global $order, $db;

		$this->code = 'image_processing_new_step2';
		$this->title = MODULE_NEW_STEP2_IMAGE_PROCESS_TEXT_TITLE;
		$this->description = MODULE_NEW_STEP2_IMAGE_PROCESS_TEXT_DESCRIPTION;
		$this->sort_order = MODULE_NEW_STEP2_IMAGE_PROCESS_SORT_ORDER;
		$this->enabled = ((MODULE_NEW_STEP2_IMAGE_PROCESS_STATUS == 'True') ? true : false);
		$this->db = $db;

    }

	function process($file) {
	    include ('includes/classes/'.FILENAME_IMAGEMANIPULATOR);
	    @set_time_limit(0);
	    $files=array();
	    if ($dir= opendir(DIR_FS_CATALOG_ORIGINAL_IMAGES)){
	        while ($file = readdir($dir)) {
	            if ((is_file(DIR_FS_CATALOG_ORIGINAL_IMAGES.$file)) &&
	                ($file !="index.html") &&
	                ($file !="Thumbs.db")
	            ) {
	                if ((!is_file(DIR_FS_CATALOG_THUMBNAIL_IMAGES.$file)) ||
	                    (!is_file(DIR_FS_CATALOG_INFO_IMAGES.$file)) ||
	                    (!is_file(DIR_FS_CATALOG_POPUP_IMAGES.$file))
	                ) {
	                    $files[]=array('id' => $file, 'text' =>$file);
	                }
	            }
	        }
	        closedir($dir);
	    }
	    for ($i=0;$n=10,$i<$n;$i++) {
	        $products_image_name = $files[$i]['text'];
	        if (!is_file(DIR_FS_CATALOG_THUMBNAIL_IMAGES.$files[$i]['text'])) { require(DIR_WS_INCLUDES . 'product_thumbnail_images.php'); }
	        if (!is_file(DIR_FS_CATALOG_INFO_IMAGES.$files[$i]['text'])) { require(DIR_WS_INCLUDES . 'product_info_images.php'); }
	        if (!is_file(DIR_FS_CATALOG_POPUP_IMAGES.$files[$i]['text'])) {    require(DIR_WS_INCLUDES . 'product_popup_images.php'); }
	    }
	    redirect(href_link(FILENAME_MODULE_EXPORT, 'set=' . $_GET['set'] . '&action=save&module=image_processing_new_step2'));
	}

	function display() {
	    return array('text' =>
	                            IMAGE_EXPORT_TYPE.'<br>'.
	                            IMAGE_EXPORT.'<br>'.
	                            '<br>' . button(BUTTON_REVIEW_APPROVE) . '&nbsp;' .
	                            button_link(BUTTON_CANCEL, href_link(FILENAME_MODULE_EXPORT, 'set=' . $_GET['set'] . '&module=image_processing_new_step2')));


	}

    function check() {
		if(!isset($this->_check)) {
			$check = $this->db->db_query("SELECT configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key = 'MODULE_NEW_STEP2_IMAGE_PROCESS_STATUS'");
			$this->_check = $check->_numOfRows;
		}
		return $this->_check;
    }

    function install() {
		$this->db->db_query("INSERT INTO " . TABLE_CONFIGURATION . " (configuration_key, configuration_value,  configuration_group_id, sort_order, set_function, date_added) VALUES ('MODULE_NEW_STEP2_IMAGE_PROCESS_STATUS', 'True',  '6', '1', 'cfg_select_option(array(\'True\', \'False\'), ', now())");
	}

    function remove() {
		$this->db->db_query("DELETE FROM " . TABLE_CONFIGURATION . " WHERE configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }

    function keys() {
		return array('MODULE_NEW_STEP2_IMAGE_PROCESS_STATUS');
    }
}
?>